<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <title>首页</title>
    <%@ include file="/base/jsp/include.jsp"%>
    <style type="text/css">
    html,html body
    {
        font-family:宋体;
        font-size:13px;
    }
    h2
    {
        font-family: "Trebuchet MS",Arial,sans-serif;
    }
    p
    {
        line-height:22px;
    }
    </style>
    <script type="text/javascript">
    var id = "${sessionUser.id}";
	$(function(){
		getCurDate();
		setInterval("getCurDate()", 1000);
		
		if (id != '') {
			$.post(sy.contextPath + '/waimaiStore/findById.do', {
				id : id
			}, function(result) {
				if (result) {
					$("#balance").html(result.balance+"元");
					$('form').form('load', result);
				}
			}, 'json');
			
		}
		
		$('#p').panel({    
			  width:500,    
			  height:200,    
			  title: '快捷设置',    
			  collapsible:true,
			  tools: [{    
			    iconCls:'icon-save',    
			    handler:function(){
			    	if ($('form').form('Validate')) {
						var obj = sy.serializeObject($('form'));
						var url = sy.contextPath + '/waimaiStore/save.do';
						$.post(url, obj, function(result) {
							if (result.code==0) {
								parent.$.messager.i('保存成功 ');
							} else {
								parent.$.messager.e('保存失败 ,'+result.msg);
							}
						}, 'json');
					}
				}    
			  }]    
			});
	});
	
	function getCurDate() {
		var d = new Date();
		var week;
		switch (d.getDay()) {
		case 1:
			week = "星期一";
			break;
		case 2:
			week = "星期二";
			break;
		case 3:
			week = "星期三";
			break;
		case 4:
			week = "星期四";
			break;
		case 5:
			week = "星期五";
			break;
		case 6:
			week = "星期六";
			break;
		default:
			week = "星期天";
		}
		var years = d.getYear() < 1000 ? (d.getYear() + 1900)
				: d.getYear();
		var month = add_zero(d.getMonth() + 1);
		var days = add_zero(d.getDate());
		var hours = add_zero(d.getHours());
		var minutes = add_zero(d.getMinutes());
		var seconds = add_zero(d.getSeconds());
		var ndate = years + "年" + month + "月" + days + "日 "
				+ hours + ":" + minutes + ":" + seconds + " "
				+ week;
		document.getElementById('dd').innerHTML = ndate;
	}
	function add_zero(temp) {
		if (temp < 10)
			return "0" + temp;
		else
			return temp;
	}
	</script>
  </head>
  <body>
  	<h2><span id="dd"></span></h2>
    <p>欢迎您：${sessionUser.rolename}(${sessionUser.account})</p>
    <br />
    <div id="p" style="padding:10px;">
	    <form id="form" method="post">
	    	<input name="id" type="hidden" />
	    	<table style="table-layout:fixed;" border="0" cellspacing="0">
	    		<tr>
					<th style="width:100px;">账户余额：</th>
					<td id="balance">
					</td>
				</tr>
				<tr>
					<th style="width:100px;">营业状态：</th>
					<td>
						<select name="status" class="easyui-combobox" data-options="required:true,editable:false" panelHeight='auto'>
							<option value='1' selected="selected">正常营业</option>
							<option value='2'>忙碌</option>
							<option value='3'>休息</option>
						</select>
					</td>
				</tr>
				<tr>
					<th style="width:100px;">公告：</th>
					<td>
						<input id="news" style="width:400px;height:100px;" name="news" class="easyui-textbox" data-options="multiline:true,validType:'length[0,200]'"/>
					</td>
				</tr>
			</table>
	    </form>
	</div>    
</body>
</html>
